package com.serkol.driving.learning.handler;

import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.serkol.driving.learning.entity.Users;

import java.util.HashMap;
import java.util.Map;

public class ParseUtils {


    public static Users parseUsersDetail(WxMaUserInfo wxMaUserInfo) {
        Users usersDetail = new Users();
        usersDetail.setAvatar(wxMaUserInfo.getAvatarUrl());
        usersDetail.setNickname(wxMaUserInfo.getNickName());
        usersDetail.setSex(Integer.parseInt(wxMaUserInfo.getGender()));
       // usersDetail.set(wxMaUserInfo.getCity());
     //   usersDetail.setCountry(wxMaUserInfo.getCountry());
      //  usersDetail.setLanguage(wxMaUserInfo.getLanguage());
      //  usersDetail.setOpenid(wxMaUserInfo);
        usersDetail.setUnionid(wxMaUserInfo.getUnionId());


        return usersDetail;
    }


    public static Map<String,Object> parseTokenDetail(Users usersDetail) {
        Map<String,Object> map=new HashMap<>();
        map.put("avatar",usersDetail.getAvatar());
        map.put("nickName",usersDetail.getNickname());
        map.put("sex",usersDetail.getSex());
        map.put("openId",usersDetail.getOpenid());
        map.put("phone",usersDetail.getPhone());
        map.put("invite",usersDetail.getInvite());

  /*      usersDetail.setHeadimgurl(wxMaUserInfo.getAvatarUrl());
        usersDetail.setNickname(wxMaUserInfo.getNickName());
        usersDetail.setSex(Integer.parseInt(wxMaUserInfo.getGender()));
        usersDetail.setCity(wxMaUserInfo.getCity());
        usersDetail.setCountry(wxMaUserInfo.getCountry());
        usersDetail.setLanguage(wxMaUserInfo.getLanguage());
        usersDetail.setOpenid(wxMaUserInfo.getOpenId());
        usersDetail.setUnionid(wxMaUserInfo.getUnionId());*/


        return map;
    }
}
